home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / comm / irc / epic4-mos.lha / share / epic / help / 7_docs / Special_vars < prev    next >
Encoding:
Text File  |  2001-03-22  |  5.8 KB  |  117 lines

  1. Special Variables and Expandos                                              
  2.  
  3. In addition to normal variables created with ASSIGN, and the builtin SET
  4. variables, EPIC also supports a number of reserved, dynamic variables,
  5. sometimes referred to as expandos.  They are special in that the client is
  6. constantly updating their values automatically.  There are also numerous
  7. variable modifiers available.
  8.  
  9.    Modifier          Description                                            
  10.    $variable         A normal variable, expanding to the first match of:
  11.                      |  1) a variable created with ASSIGN or @
  12.                      |  2) an internal SET variable
  13.                      |  3) an environment variable
  14.                      |  4) an empty string
  15.    $[num]variable    Expands to the variables value, with 'num' width.  If
  16.                      | the number is negative, the value is right-aligned.
  17.                      | The value is truncated or padded to meet the width.
  18.    $#variable        Expands to the number of words in $variable. If $variable
  19.                      | is omitted, it assumes $*
  20.    $@variable        Expands to the number of characters in $variable. if
  21.                      | $variable is omitted, it assumes $*
  22.    $($subvariable)   This is somewhat similar to a pointer, in that the
  23.                      | value of $subvar is taken as the name of the
  24.                      | variable to expand to.  Nesting is allowed.
  25.    ${expression}     Expands to the return value of the expression.  In
  26.                      | addition, ${} permits the value to be embedded in
  27.                      | another string unambiguously.
  28.    $!history!        Expands to a matching entry in the client's command
  29.                      | history, wildcards allowed.
  30.    $"some text"      Uses 'text' as an input prompt, and returns whatever
  31.                      | is typed next.  This usage is deprecated, use the
  32.                      | INPUT command instead.
  33.  
  34. Whenever an alias is called, these expandos are set to the arguments passed
  35. to it.  If none of these expandos are used in the alias, or the $() form
  36. shown above, any arguments passed will automatically be appended to the last
  37. command in the alias.
  38.  
  39.    Expando   Description                                                    
  40.    $*        expands to all arguments passed to an alias
  41.    $n        expands to argument 'n' passed to an alias (counting from zero)
  42.    $n-m      expands to arguments 'n' through 'm' passed to an alias
  43.    $n-       expands to all arguments from 'n' on passed to an alias
  44.    $-m       expands to all arguments up to 'm' passed to an alias
  45.    $~        expands to the last argument passed to an alias
  46.  
  47. These variables are set and updated dynamically by the client.  The case of
  48. $A .. $Z is important.  Also note that $A .. $Z can be overridden by ASSIGN,
  49. so it is usually good practice to make variable names 2 or more characters
  50. long.
  51.  
  52.    Variable   Description                                                   
  53.    $,         last person who sent you a MSG
  54.    $.         last person to whom you sent a MSG
  55.    $:         last person to join a channel you are on
  56.    $;         last person to send a public message to a channel you are on
  57.    $A         text of your AWAY message, if any
  58.    $B         body of last MSG you sent
  59.    $C         current channel
  60.    $D         last person that NOTIFY detected a signon for
  61.    $E         idle time
  62.    $F         time client was started, $time() format
  63.    $H         current server numeric being processed
  64.    $I         channel you were last INVITEd to
  65.    $J         client version text string
  66.    $K         current value of CMDCHARS
  67.    $L         current contents of the input line
  68.    $M         modes of current channel, if any
  69.    $N         current nickname
  70.    $O         value of STATUS_OPER if you are an irc operator
  71.    $P         if you are a channel operator in $C, expands to a '@'
  72.    $Q         nickname of whomever you are QUERYing
  73.    $R         version of current server
  74.    $S         current server name
  75.    $T         target of current input (channel or QUERY nickname)
  76.    $U         value of cutbuffer
  77.    $V         client release date (numeric version string)
  78.    $W         current working directory
  79.    $X         your /userhost $N address (user@host)
  80.    $Y         value of REALNAME
  81.    $Z         time of day (hh:mm)
  82.    $$         a literal '$'
  83.  
  84. For example, assume you have the following alias:
  85.  
  86.    alias blah { msg $D Hi there!  }
  87.  
  88. If /blah is passed any arguments, they will automatically be appended to the
  89. MSG text.  For example:
  90.  
  91.    /blah oops                          /* command as entered */
  92.    "Hi there! oops"                    /* text sent to $D */
  93.  
  94. One of the more confusing expandos to look at is the $() form.  It evaluates
  95. the variable or function inside the parenthesis, and whatever is returned is
  96. used as the name of the variable to expand.  For example:
  97.  
  98.    assign foo blah                     /* inside variable */
  99.    assign blah 10                      /* real variable */
  100.    /eval echo $($foo)                  /* $foo expands to "blah" */
  101.    "10"                                /* $blah expands to "10" */
  102.  
  103. Another useful form is ${}.  In general, variables can be embedded inside
  104. strings without problems, assuming the surrounding text could not be
  105. misinterpreted as part of the variable name.  This form guarantees that
  106. surrounding text will not affect the expression's return value.
  107.  
  108.    /eval echo foo$Nfoo                 /* breaks, looks for $nfoo */
  109.    /eval echo foo${N}foo               /* ${N} returns current nickname */
  110.    fooYourNickfoo                      /* returned by above command */
  111.    /eval echo ${[foo]}bar              /* expression parser may be used */
  112.    foobar                              /* returned by above command */
  113.  
  114. See Also:
  115.    Expressions(7); Programming(7); assign(5); input(5)
  116.  
  117.